const Koa = require('koa')
const cors = require('koa2-cors');
const koaBody = require('koa-body');
const fs = require('fs');
const path = require('path')
var format = require('date-format');
const {dirExists} = require('../middleware/common.middleware')
const router = require('../routes')
const app = new Koa()

app.use(cors());
app.use(koaBody());



app.use(router.routes())
app.use(router.allowedMethods()); // 作用： 这是官方文档的推荐用法,我们可以看到router.allowedMethods()用在了路由匹配router.routes()之后,所以在当所有路由中间件最后调用.此时根据ctx.status设置response响应头

module.exports = app